﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.ServiceModel;
using System.ServiceModel.Description;
using System.Diagnostics;
using System.Windows.Forms;
using Contract;
using System.IO;
using System.Net;
using System.Net.Sockets;

namespace client
{  
    
    public partial class Cpassword : Form
    {
        string PCN;
        public Cpassword(string pcn)
        {   
            PCN = pcn;
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
  
            NetTcpBinding binding = new NetTcpBinding();
            binding.TransferMode = TransferMode.Streamed;
            binding.SendTimeout = TimeSpan.MaxValue;
            binding.MaxReceivedMessageSize = 9223372036854775807;

            EndpointAddress address = new EndpointAddress("net.tcp://" + Dns.GetHostAddresses(Environment.MachineName)[2].ToString() + ":5000/DataUploader");

            ChannelFactory<IDataUploader> channel = new ChannelFactory<IDataUploader>(binding, address);
            IDataUploader Proxy = channel.CreateChannel();
            string newpassword = textBox1.Text.Trim();
            string confirmpwd = textBox2.Text.Trim();
          
             try
             {

                 if (newpassword == "" || confirmpwd == "" || newpassword != confirmpwd)
                 {
                     MessageBox.Show("No empty! No differen!");
                 }
                 else 
                 {
                     Proxy.cpassword(newpassword,PCN);
                     MessageBox.Show("Done!");
                 }


             }





            catch
            {
                MessageBox.Show("fail");
            }
        }
    }
}
